home *** CD-ROM | disk | FTP | other *** search
- Path: news.ov.com!news
- From: glenn@ov.com (Fletcher.Glenn@ov.com)
- Newsgroups: comp.lang.c
- Subject: Re: accessing structures via pointers
- Date: 8 Apr 1996 15:45:32 GMT
- Organization: OpenVision
- Message-ID: <4kbcas$dir@spanky.pls.ov.com>
- References: <1996Apr8.144012.25767@leeds.ac.uk>
- Reply-To: glenn@ov.com
- NNTP-Posting-Host: foghorn.pls.ov.com
-
- In article 25767@leeds.ac.uk, csyamc@scs.leeds.ac.uk (A M Casey) writes:
- >Hi I'm calling the function getgrent(), which resturns a structure
- >as defined in grp.h, ie
- >
- > struct group {
- > char *gr_name; /* the name of the group */
- > char *gr_passwd; /* the encrypted group password */
- > gid_t gr_gid; /* the numerical group ID */
- > char **gr_mem; /* vector of pointers to member names */
- > };
- >the trouble is it returns a pointer to the structure:
- >
- >struct group *getgrent(void);
- >
- >
- >and I havent got a clue how to access it. I've lookied at the faq, but
- >I'm still stuck.
- >
- >I need something like
- >
- >printf("the group name is %s\n",tempgroup.gr_name);
- >
- >but that doesnt work because tempgroup is a pointer.
- >
- >How do I do this?
- >
- >Cheers
- >
- >Andy
- >
-
-
-
- Try:
-
- struct group *gp;
-
- gp = getgrent(gid);
-
- printf("The group name is %s\n", gp->gr_name);
-
- Fletcher.Glenn@ov.com
-
-